package com.art.sunflower.mapper;

import com.art.sunflower.enumeration.CourseStatusType;
import com.art.sunflower.pojo.Course;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface CourseMapper {
    @Insert("insert into course(master_id,course_name,introduce,requirement,teach_fee,material_fee,cooperation_id) " +
            "values(#{masterId},#{courseName},#{introduce},#{requirement},#{teachFee},#{materialFee},#{cooperationId})")
    int addCourse(Course course);

    @Delete("delete from course where id=#{id}")
    int deleteById(int id);

    @Update("update course set course_name=#{courseName},introduce=#{introduce},requirement=#{requirement}," +
            "teach_fee=#{teachFee},material_fee=#{materialFee},cooperation_id=#{cooperationId} where id=#{id}")
    int updateCourseById(int id, String courseName, String introduce, String requirement, int teachFee, int materialFee, int cooperationId);

    @Select("select * from course_cooperation_user_view where username = #{username}")
    List<Map<String, Object>> findAllCourse(String username);

    @Select("select * from course_cooperation_user_view where id=#{id}")
    Map<String, Object> selectOneCourse(int id);

    @Update("update course set status=#{statu} where id=#{id}")
    int updateCourseStatu(int id, CourseStatusType statu);

    @Select("select * from course_cooperation_user_view where status='未审定'")
    List<Map<String, Object>> findAllCourseByAdmin(Integer pagenum, Integer pagesize);

    @Select("select * from course_cooperation_user_view where status='审定通过' or status='审定失败'")
    List<Map<String, Object>> findAllCourseByAdmin2();

    @Update("update course set teach_fee=#{teachFee},material_fee=#{materialFee},status=#{statu} where id=#{id}")
    int courseStatuCheck(int id, int teachFee, int materialFee, CourseStatusType statu);

    @Select("select id from user")
    int selectMst(int id);

    @Select("select value, label from course_name_view where status='审定通过' or status='审定失败'")
    List<Map<String, Object>> selectName();

    @Select("select * from course_cooperation_user_view where id=#{id}")
    Map<String, Object> findOneCourseByAdmin(int id);

}
